package com.example.student.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.domain.pojo.KnowledgePoint;
import com.example.student.mapper.KnowledgePointMapper;
import com.example.student.service.KnowledgePointService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KnowledgePointServiceImpl extends ServiceImpl<KnowledgePointMapper, KnowledgePoint> implements KnowledgePointService {


    @Override
    public List<KnowledgePoint> getKnowledgeByCourseId(String courseId) {
        LambdaQueryWrapper<KnowledgePoint> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(KnowledgePoint::getCourseId, courseId);
        return this.list(queryWrapper);
    }

    @Override
    public Page<KnowledgePoint> getKnowledgeByCourseIdPage(String courseId, Integer pageNum, Integer pageSize) {
        LambdaQueryWrapper<KnowledgePoint> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(KnowledgePoint::getCourseId, courseId);
        return this.page(new Page<>(pageNum, pageSize), queryWrapper);
    }
}
